import { defineStore } from "pinia"
import { useLocalStorage } from '@/hooks/useLocalStorage'

// 第一个参数是应用程序中 store 的唯一 id
const menusStore = defineStore('menus', {
  state: () => {
    return {
      // 控制菜单是展开还是收缩，展开为true
      collapse: false,
      menus: [] as object[]
    }
  },
  actions: {
    updateMenus (menus: object[]) {
      useLocalStorage('menus', menus)
      this.menus = menus
    }
  }
})

export default menusStore